<template>
  <el-table :data="goodsList" stripe style="width: 100%">
    <el-table-column prop="dtitle" label="标题"/>
    <el-table-column prop="dfetchdata" width="200px" label="取件时间"/>
    <el-table-column prop="dname" label="取件人"/>
    <el-table-column prop="dfetchname" label="收件人"/>
    <el-table-column prop="dfetchphone" label="收件人手机号"/>
    <el-table-column prop="dstatus" label="状态" #default="scope">
      {{
        scope.row.dstatus === 1 ? '等待分配取件人' : scope.row.dstatus === 2 ? '等待取件' : scope.row.dstatus === 3 ? '捐赠成功' : '其他'
      }}
    </el-table-column>
    <el-table-column fixed="right" label="操作" width="180px">
      <template #default="scope">
        <el-button v-if="scope.row.dstatus === 1" @click="cacle(scope.row.did)" type="primary" size="small"
                   round>取消
        </el-button>
      </template>
    </el-table-column>
  </el-table>
  <!--  分页-->
  <div class="pageBox">
    <el-pagination
        :page-size="5"
        small
        background
        layout="prev, pager, next"
        :total="total"
        class="mt-4"
        v-model:current-page="nowPage"
        @update:current-page="getData()"
    />
  </div>
</template>

<script>
import doThis from "@/api/getData";
import {ElMessage} from "element-plus";

export default {
  name: "DonateGoods",
  data() {
    return {
      goodsList: [],
      total: 0,
      nowPage: 1,
    }
  },
  methods: {
    cacle(did) {
      doThis.doGet("/donategoods/changeStatus", {did: did, dstatus: 4}).then(res => {
/*        alert(res.msg)
        if (res.code === '0') {

        }*/
        if (res.code === "0") {
          ElMessage({
            message: res.msg,
            type: 'success',
          })
          this.getData()
        }else {
          ElMessage.error(res.msg)
        }
      })
    },
    //获取数据
    getData() {
      doThis.doGet("/donategoods/findUser",{pageNum: this.chNowPage, vid: this.tempVid}).then(res => {
        if (res.code === '0'){
          this.goodsList = res.data.list
          this.total = res.data.count
          console.log(this.goodsList)
        }else {
          ElMessage(res.msg)
        }

      })
    },
  },
  mounted() {
    this.getData()
  }
}
</script>

<style>

</style>